package com.easyui.bean;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.easyui.DB.OperateDB;
import com.easyui.common.SelAttach;
import com.easyui.common.SelStudent;

public class Project {
	private int pno;
	private String pname;
	private String pcont;
	private String stime;
	private String etime;
	private String pubno;
	private String pubname;//发布者(老师)姓名
	private String progress;
	private String allowsee;
	private String attach;
	private String stimef;// 以下四个参数供查询时使用
	private String stimet;
	private String etimef;
	private String etimet;
	private String stage;
	private List<Map> attachList= null;//项目附件
	private List<Map> memberList = null;
	//private List<String> memberID = null;
	
	public Project() {}
	
	/**
	 * 初始化项目信息
	 * 返回一个Project对象
	 * @param pname
	 * @param stimef
	 * @param stimet
	 * @param progress
	 * @param etimef
	 * @param etimet
	 */
	public Project(String pname, String pubname, String stimef, String stimet, String progress, String etimef, String etimet) {
		if(pname != null && !pname.trim().equals("")) {
			this.pname = pname.trim();
		} else {
			this.pname = pname;
		}
		
		if(pubname != null && !pubname.trim().equals("")) {
			this.pubname = pubname.trim();
		} else {
			this.pubname = pubname;
		}
		
		if(stimef != null && !stimef.trim().equals("")) {
			this.stimef = stimef.trim();
		} else {
			this.stimef = stimef;
		}
		
		if(stimet != null && !stimet.trim().equals("")) {
			this.stimet = stimet.trim();
		} else {
			this.stimet = stimet;
		}
		
		if(etimef != null && !etimef.trim().equals("")) {
			this.etimef = etimef.trim();
		} else {
			this.etimef = etimef;
		}
		
		if(etimet != null && !etimet.trim().equals("")) {
			this.etimet = etimet.trim();
		} else {
			this.etimet = etimet;
		}
		
		if(progress != null && !progress.trim().equals("")) {
			if(progress.trim().equals("all")) {
				this.progress = "";
			} else {
				this.progress = progress.trim();
			}
		}
	}
	
	/**
	 * 将Map对象转换成Project对象
	 * @param map
	 */
	public void init(Map map) {
		this.setPno((Integer)map.get("pno"));
		this.setPname((String)map.get("pname"));
		this.setPubname((String)map.get("tname"));
		this.setPcont((String)map.get("pcont"));
		this.setStime((String)map.get("stime"));
		this.setEtime((String)map.get("etime"));
		this.setPubno((String)map.get("pubno"));
		this.setProgress((String)map.get("progress"));
		this.setAllowsee((String)map.get("allowsee"));
		this.setAttach((String)map.get("isappend"));
	}
	
	/**
	 * 将学生参与的项目信息初始化
	 * @param map
	 */
	public void initSP(Map map) {
		this.setPno((Integer)map.get("pno"));
		this.setPname((String)map.get("pname"));
		this.setPubname((String)map.get("tname"));
		this.setPcont((String)map.get("pcont"));
		this.setStime((String)map.get("stime"));
		this.setEtime((String)map.get("etime"));
		this.setPubno((String)map.get("pubno"));
		this.setProgress((String)map.get("progress"));
		this.setAllowsee((String)map.get("allowsee"));
		this.setAttach((String)map.get("isappend"));
		this.setStage((String)map.get("stage"));
	}
	
	public void initDetail(Map map) {
		if(this.getAttach().equals("1")) {
			this.setAttachList(new SelAttach().getPAttachName(this.getPno()));
		}
		this.setMemberList(new SelStudent().getPMember(this.getPno()));
	}
	
	public String getStage() {
		return stage;
	}

	public void setStage(String stage) {
		this.stage = stage;
	}
	
	public List<Map> getAttachList() {
		return attachList;
	}

	/**
	 * 通过pno获得附件名的链接
	 * @param pno
	 */
	public void setAttachList(List<Map> attachList) {
		this.attachList = attachList;
	}

	public List<Map> getMemberList() {
		return memberList;
	}

	
	public void setMemberList(List<Map> memberList) {
		this.memberList = memberList;
	}

	public String getPubname() {
		return pubname;
	}

	public void setPubname(String pubname) {
		this.pubname = pubname;
	}
	
	public String getStimef() {
		return stimef;
	}

	public void setStimef(String stimef) {
		this.stimef = stimef;
	}

	public String getStimet() {
		return stimet;
	}

	public void setStimet(String stimet) {
		this.stimet = stimet;
	}

	public String getEtimef() {
		return etimef;
	}

	public void setEtimef(String etimef) {
		this.etimef = etimef;
	}

	public String getEtimet() {
		return etimet;
	}

	public void setEtimet(String etimet) {
		this.etimet = etimet;
	}
	
	public int getPno() {
		return pno;
	}
	public void setPno(int pno) {
		this.pno = pno;
	}
	public String getPname() {
		return pname;
	}
	public void setPname(String pname) {
		this.pname = pname;
	}
	public String getPcont() {
		return pcont;
	}
	public void setPcont(String pcont) {
		this.pcont = pcont;
	}
	public String getStime() {
		return stime;
	}
	public void setStime(String stime) {
		this.stime = stime;
	}
	public String getEtime() {
		return etime;
	}
	public void setEtime(String etime) {
		this.etime = etime;
	}
	public String getPubno() {
		return pubno;
	}
	public void setPubno(String pubno) {
		this.pubno = pubno;
	}
	public String getProgress() {
		return progress;
	}
	public void setProgress(String progress) {
		this.progress = progress;
	}
	public String getAllowsee() {
		return allowsee;
	}
	public void setAllowsee(String allowsee) {
		this.allowsee = allowsee;
	}
	public String getAttach() {
		return attach;
	}
	public void setAttach(String attach) {
		this.attach = attach;
	}
}
